package com.bdzt.beidoubox.activity;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.bdzt.beidoubox.R;
import com.bdzt.beidoubox.adapter.FamilyAdapter;
import com.bdzt.beidoubox.entity.FamilyInfo;

import java.util.ArrayList;
import java.util.List;

/**
 * 家人信息列表
 */
public class FamilyListActivity extends BaseActivity {
    private ListView lv_familyList;
    private List<FamilyInfo> list;
    private FamilyAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_family_list);
        initView();
        initData();
    }

    private void initData() {
        for (int i=0;i<10;i++){
            FamilyInfo info = new FamilyInfo();
            info.setTel("1888956622"+i);
            info.setName("Tom"+i+"me");
            info.setMail("1888956622"+i+"@qq.com");
            list.add(info);
        }

        adapter.notifyDataSetChanged();

    }

    private void initView() {
        list=new ArrayList<>();
        adapter=new FamilyAdapter(list,FamilyListActivity.this);

        lv_familyList = (ListView) findViewById(R.id.lv_familyList);
        lv_familyList.setAdapter(adapter);
        findViewById(R.id.tv_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FamilyListActivity.this.finish();
            }
        });


        lv_familyList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            }
        });
    }
}
